package com.codeti.core.wordcount;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.mapreduce.Job;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

/**
 * @author: zhenzhong.wang@honeywell.com
 * @date: 2019/9/23 4:47 PM
 */
public class WordCountMR {

  private static Configuration conf;
  private static FileSystem fs;

  static {
    conf = new Configuration();
    conf.set("dfs.relication", "2");
    // 远程连接需要在FileSystem.get中设置URI
    //    conf.set("fs.defaultFS", "hdfs://hadoop1:9000");


    // 设置hadoop用户为root，欺骗hdfs
//    Properties properties = new Properties();
//    properties.setProperty("HADOOP_USER_NAME", "root");
//    System.setProperties(properties);

    try {
      fs = FileSystem.get(new URI("hdfs://hadoop1:9000"), conf, "root");
    } catch (IOException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }
  }

  public static void main(String[] args) throws IOException {

    Job job = Job.getInstance(conf);

  }
}
